<!DOCTYPE html>
<html>
<head>
    <title>住宅房源导入</title>
<#include "../common/common.ftl"/>
</head>
<body style="overflow-y: hidden;">
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">房源数据：</div>
        <div class="layui-card-body">
            <form class="layui-form" id="houseArrayForm">
                <input type="hidden" name="azProjectId" value="${(azProject.id)!}"/>
                <textarea class="layui-textarea" cols="150" rows="13" name="houseArray"
                          lay-verify="required" style="resize:none;background-color:  #FFFFE0;"></textarea>
                <button class="layui-btn layui-btn-fluid"
                        style="margin-top: 10px;" lay-submit="" lay-filter="submit">立即导入
                </button>
            </form>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">数据导入说明</div>
        <div class="layui-card-body" style="color: red;">
            1、请按照下方图片所示红色框线内数据粘贴到上方文本框内，并确认数据正确性；【红色为必填】<br/>
            2、数据格式： 幢号、户号、所在层数、房屋类型、户型、套内建筑面积、公摊面积、阳台面积、封闭阳台数量、非封闭阳台数量、房源状态、备注，每一列都不能为空；<br/>
            3、房源类型：数据对应格式：【真实名字】-【数据对应数字】,如下:<#list houseTypeMap?keys as key>【${key}】-【${houseTypeMap[key]}】</#list>；<br/>
            4、导入期间请耐心等待，勿进行其他操作。
            <img src="/images/houseImport.png" style="max-width: 100%;"/>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['form'], function () {
        var $ = layui.jquery, form = layui.form, parentIndex = parent.layer.getFrameIndex(window.name);
        //监听提交
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: 'importHouse',
                type: 'post',
                data: $("#houseArrayForm").serialize(),
                async: false,
                success: function (data) {
                    if (data.code == "0001") {
                        layer.alert(data.message, function (index) {
                            parent.layer.close(parentIndex);
                        })
                        parent.loadData();
                    } else {
                        layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>